package com.kzj.common.util;

import org.springframework.util.DigestUtils;

import java.util.UUID;

public class PasswordUtil {
    public static String encode(String key)
    {
        return DigestUtils.md5DigestAsHex(key.getBytes());
    }

    public static String decode(String code)
    {
        return "";
    }
    public static String encodeBySalt(String key,String salt)
    {
        return encode(key+salt);
    }
    public static String getSalt()
    {
        String uuid = UUID.randomUUID().toString().replace("-","");
        //TODO 处理得到salt
        String salt=uuid;
        return salt;
    }
    public static boolean checkPassword(String truePassword,String password,String salt)
    {
        return truePassword.equals(encodeBySalt(password,salt));
    }



}
